<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath }"></c:set>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>用户登录</title>
<link href="${ctx}/css/framework/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="${ctx }/css/index.css">

</head>

<body>
	<c:import url="nav.jsp"></c:import>
	<!-- 注册模块 -->
	<div class="container">
		<ol class="breadcrumb">
			<li><a class="returnBack" href="${ctx }/toHome">&lt; 回到首页</a></li>
			<li class="active">登录</li>
		</ol>

		<div class="row grey main">
			<div class="col-md-6 col-md-offset-3 ">
				<div class="row">
					<div class="col-md-6 col-md-offset-3 ">
						<img src="${ctx}/images/index/login_logo.png"
							class="img-responsive img-rounded" alt="Responsive image">
					</div>
				</div>
				<div class="row main">
					<form class="form-horizontal" role="form">
						<div class="form-group">
							<label for="firstname" class="col-sm-2 control-label">账号</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="mail" name="mail"
									placeholder="请输入你的邮箱">
							</div>
							<div class="col-sm-2"></div>
						</div>
						<div class="form-group">
							<label for="lastname" class="col-sm-2 control-label">密码</label>
							<div class="col-sm-8">
								<input type="password" class="form-control" id="password"
									name="password" placeholder="请输入你的密码">
							</div>
							<div class="col-sm-2"></div>
						</div>

						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-8">
								<button class="btn btn-primary btn-block" id="u_login">登录</button>
							</div>
						</div>

						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-4">
								<a href="${ctx }/forgetpwd.html">找回密码?</a>
							</div>

							<div class="col-sm-offset-1 col-sm-4">
								<a href="${ctx }/register.html">立即注册</a>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<c:import url="footer.jsp"></c:import>
	<script src="${ctx }/js/framework/bootstrap.min.js"></script>
	<script src="${ctx }/js/jquery.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#u_login").click(function() {
				$.ajax({
					async : false,
					type : "POST",
					url : "api_login",
					dataType : 'JSON',
					data : {
						mail : $("#mail").val(),
						password : $("#password").val()
					},
					success : function(result) {
						//
						
						if (result.state == 200) {
							
							window.location = result.goPage;
							alert("登录成功，正在跳转。。。");
							
						} else {
							alert("密码或账号错误");
						}
					}
				});

			});
		});
	</script>

</body>
</html>